package com.neutech.dome;

import com.neutech.entity.Category;
import com.neutech.entity.Product;
import com.neutech.mapper.CategoryMapper;
import com.neutech.mapper.ProductMapper;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public class Demo6 {
    public static void main(String[] args) {
        SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(
                Demo1.class.getClassLoader().getResourceAsStream("mybatis.xml")
        );
        //创建SQL session的对象
        SqlSession session = factory.openSession();
//        ProductMapper productMapper = session.getMapper(ProductMapper.class);
//        for (Product product : productMapper.oneToOneDemo()) {
//            System.out.println(product);
//        }
        CategoryMapper categoryMapper = session.getMapper(CategoryMapper.class);
        for (Category category : categoryMapper.oneToManyDemo()) {
            System.out.println(category);
        }
    }
}
